package com.umeox.recorder;

import android.content.Context;
import android.media.AudioManager;
import android.os.Bundle;
import android.view.Window;

import androidx.annotation.Nullable;

import com.umeox.moto.watch.themes.app.ThemeAppCompatActivity;
import com.umeox.moto.watch.themes.widget.Slider;


public class VolumeActivity extends ThemeAppCompatActivity {


    AudioManager mAudioManager;
    int currentVolume;
    int maxVolume;


    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getWindow().requestFeature(Window.FEATURE_SWIPE_TO_DISMISS);
        setContentView(R.layout.activity_volume);

        mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
        mAudioManager.setMode(AudioManager.MODE_IN_CALL);
        maxVolume = mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
        currentVolume = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC);

        Slider seekBar = findViewById(R.id.sl_volume_call);
        seekBar.setValueRange(0, maxVolume, true);
        seekBar.setValue(currentVolume, false);

        seekBar.setOnPositionChangeListener((view, fromUser, oldPos, newPos, oldValue, newValue) -> {

            mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, newValue, 0);

        });
    }


}
